﻿#include "urllineedit.h"
#include "ui_urllineedit.h"
#include "utils.h"
#include "bookmarkwidget.h"

#include <QMessageBox>
#include <QString>
#include <QTextCodec>

#pragma execution_character_set("utf-8")

URLLineEdit::URLLineEdit(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::URLLineEdit)
{
    ui->setupUi(this);

    //重新输入URL并回车
    connect(ui->urlLineInput, &QLineEdit::returnPressed, [=](){
        emit pressUrlInputLine(ui->urlLineInput->text());
    });

}

URLLineEdit::~URLLineEdit()
{
    delete ui;
}

void URLLineEdit::urlInputUpdate(QUrl url)
{
    ui->urlLineInput->setText(url.toString());
    ui->urlLineInput->setCursorPosition(0);
    ui->urlLineInput->setToolTip(url.toString());
}

void URLLineEdit::on_urlSafeCheckBtn_clicked()
{
    QMessageBox msgBox;
    msgBox.setModal(true);
    msgBox.setText("该软件暂时没有其他可手动配置的安全防护措施了");

    msgBox.setStandardButtons(QMessageBox::Ok);
    msgBox.setDefaultButton(QMessageBox::Ok);
    int ret = msgBox.exec();
}

void URLLineEdit::on_urlCollectBtn_clicked()
{
    emit markUrl(urlLineInput()->text());
}

